The first part of this analysis looks at the temporal intersubject correlation - how well the subjects data align over time. Looking at this will allow us to get a measure of “typciality” - how typical an individual subject’s brain data is.

One big caveat here (for both these analyses) is that they’re currently done using the SMOOTHED data.

library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.3     ✓ dplyr   1.0.1
## ✓ tidyr   1.1.1     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(patchwork)
library(reshape2)
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(reticulate)
library(rmatio)
reticulate::use_python("/Users/catherinewalsh/miniconda3")

load('data/behav.RData')
load('data/split_groups_info.RData')
load('data/ISC_data.RData')

se <- function(x) {
  sd(x,na.rm=TRUE)/sqrt(length(x[!is.na(x)])) 
}

source("helper_fxns/avg_ISC.R")
source("helper_fxns/corr_ISC.R")

rects <- data.frame(xstart=c(7),xend=c(9))

Temporal ISC

Want to look at which regions show a load effect.

load_effect_LOO <- fisherz(high_correct_ISC_LOO) - fisherz(low_correct_ISC_LOO)

load_effect_LOO[load_effect_LOO == -Inf] <- NA
load_effect_LOO[load_effect_LOO == Inf] <- NA

LOO_results <- data.frame(t=matrix(nrow=297),p=matrix(nrow=297), sig_05=matrix(nrow=297), sig_corrected=matrix(nrow=297))
# one sample t test against 0 

for (region in seq.int(1,297)){
  temp <- t.test(load_effect_LOO[,region])
  LOO_results$t[region] <- temp$statistic
  LOO_results$p[region] <- temp$p.value
  if (temp$p.value < 0.05){
    LOO_results$sig_05[region] <- TRUE
  } else {
    LOO_results$sig_05[region] <- FALSE
  }
  if (temp$p.value < 0.05/297){
    LOO_results$sig_corrected[region] <- TRUE
  } else {
    LOO_results$sig_corrected[region] <- FALSE
  }
}

print("Regions that show a load effect (corrected for multiple comparisons): ")
## [1] "Regions that show a load effect (corrected for multiple comparisons): "
labels[LOO_results$sig_corrected,]
##  [1] "7Networks_LH_Vis_5"                "7Networks_LH_Vis_11"              
##  [3] "7Networks_LH_Vis_18"               "7Networks_LH_Vis_21"              
##  [5] "7Networks_LH_Vis_22"               "7Networks_LH_Vis_23"              
##  [7] "7Networks_LH_Vis_27"               "7Networks_LH_DorsAttn_Post_5"     
##  [9] "7Networks_LH_DorsAttn_Post_7"      "7Networks_LH_DorsAttn_Post_9"     
## [11] "7Networks_LH_DorsAttn_Post_11"     "7Networks_LH_DorsAttn_Post_12"    
## [13] "7Networks_LH_DorsAttn_Post_13"     "7Networks_LH_DorsAttn_FEF_3"      
## [15] "7Networks_LH_SalVentAttn_FrOper_9" "7Networks_LH_SalVentAttn_PFCl_1"  
## [17] "7Networks_LH_SalVentAttn_Med_7"    "7Networks_LH_Cont_Par_2"          
## [19] "7Networks_LH_Cont_Par_6"           "7Networks_LH_Cont_PFCl_2"         
## [21] "7Networks_LH_Cont_PFCl_4"          "7Networks_LH_Cont_PFCl_7"         
## [23] "7Networks_LH_Cont_PFCl_8"          "7Networks_LH_Cont_PFCmp_1"        
## [25] "7Networks_LH_Default_Temp_1"       "7Networks_LH_Default_Temp_12"     
## [27] "7Networks_LH_Default_Temp_15"      "7Networks_LH_Default_PFC_1"       
## [29] "7Networks_LH_Default_PFC_2"        "7Networks_LH_Default_PFC_5"       
## [31] "7Networks_LH_Default_PFC_9"        "7Networks_LH_Default_PCC_6"       
## [33] "7Networks_LH_Default_PCC_7"        "7Networks_RH_Vis_6"               
## [35] "7Networks_RH_Vis_11"               "7Networks_RH_Vis_15"              
## [37] "7Networks_RH_Vis_19"               "7Networks_RH_Vis_22"              
## [39] "7Networks_RH_Vis_26"               "7Networks_RH_DorsAttn_Post_4"     
## [41] "7Networks_RH_DorsAttn_Post_9"      "7Networks_RH_DorsAttn_Post_11"    
## [43] "7Networks_RH_DorsAttn_Post_12"     "7Networks_RH_DorsAttn_Post_15"    
## [45] "7Networks_RH_DorsAttn_Post_16"     "7Networks_RH_DorsAttn_Post_17"    
## [47] "7Networks_RH_DorsAttn_Post_18"     "7Networks_RH_DorsAttn_FEF_1"      
## [49] "7Networks_RH_DorsAttn_FEF_2"       "7Networks_RH_SalVentAttn_FrOper_6"
## [51] "7Networks_RH_SalVentAttn_FrOper_7" "7Networks_RH_SalVentAttn_FrOper_8"
## [53] "7Networks_RH_SalVentAttn_Med_2"    "7Networks_RH_Cont_Par_2"          
## [55] "7Networks_RH_Cont_Par_4"           "7Networks_RH_Cont_Par_5"          
## [57] "7Networks_RH_Cont_Par_6"           "7Networks_RH_Cont_PFCl_8"         
## [59] "7Networks_RH_Cont_Cing_1"          "7Networks_RH_Default_Par_4"       
## [61] "7Networks_RH_Default_Temp_1"       "7Networks_RH_Default_Temp_2"      
## [63] "7Networks_RH_Default_PFCm_3"       "7Networks_RH_Default_PFCm_9"
sig_LOO <- load_effect_LOO[,LOO_results$sig_corrected]

visual <- sig_LOO[,c(1:7,34:39)]
dorsal_attn <- sig_LOO[,c(8:14,40:49)]
ventral_attn <- sig_LOO[,c(15:17,50:53)]
FPCN <- sig_LOO[,c(18:23,54:59)]
DMN <- sig_LOO[,c(25:33,61:64)]

network_avg_LOO <- data.frame(visual=rowMeans(visual), DAN = rowMeans(dorsal_attn), VAN = rowMeans(ventral_attn), FPCN = rowMeans(FPCN), DMN = rowMeans(DMN))

LOO - all subjects

data_for_plot <- data.frame(network_avg_LOO, PTID = constructs_fMRI$PTID, BPRS = p200_clinical_zscores$BPRS_TOT[p200_clinical_zscores$PTID %in% constructs_fMRI$PTID], L3_acc = p200_data$XDFR_MRI_ACC_L3[p200_data$PTID %in% constructs_fMRI$PTID], omnibus_span = constructs_fMRI$omnibus_span_no_DFR_MRI)

data_for_plot$BPRS[data_for_plot$BPRS > 4] <- NA

plot_list <- list()

for (network in seq.int(1,5)){
  for (measure in seq.int(7,9)){
    plot_list[[colnames(data_for_plot)[network]]][[colnames(data_for_plot)[measure]]] <- ggplot(data=data_for_plot, aes_string(x= colnames(data_for_plot)[measure], y = colnames(data_for_plot)[network]))+
      geom_point()+
      stat_smooth(method="lm")+
      theme_classic()
  }
}

DAN/L3 acc, trend with BPRS DMN with L3 acc

plot_list[["visual"]][["omnibus_span"]]+ plot_list[["visual"]][["L3_acc"]] + plot_list[["visual"]][["BPRS"]] +
  plot_layout(ncol=2)+
  plot_annotation("Average temporal ISC in Visual ROIs")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

for (measure in seq.int(7,9)){
  print(colnames(data_for_plot)[measure])
  print(cor.test(data_for_plot$visual, data_for_plot[,measure]))
}
## [1] "BPRS"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$visual and data_for_plot[, measure]
## t = -0.77458, df = 167, p-value = 0.4397
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20890473  0.09195905
## sample estimates:
##         cor 
## -0.05983157 
## 
## [1] "L3_acc"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$visual and data_for_plot[, measure]
## t = 1.7426, df = 168, p-value = 0.08323
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.01762173  0.27818115
## sample estimates:
##       cor 
## 0.1332459 
## 
## [1] "omnibus_span"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$visual and data_for_plot[, measure]
## t = 0.13039, df = 168, p-value = 0.8964
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1406681  0.1603306
## sample estimates:
##        cor 
## 0.01005913
plot_list[["FPCN"]][["omnibus_span"]]+ plot_list[["FPCN"]][["L3_acc"]] + plot_list[["FPCN"]][["BPRS"]] +
  plot_layout(ncol=2)+
  plot_annotation("Average temporal ISC in FPCN ROIs")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

for (measure in seq.int(7,9)){
  print(colnames(data_for_plot)[measure])
  print(cor.test(data_for_plot$FPCN, data_for_plot[,measure]))
}
## [1] "BPRS"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$FPCN and data_for_plot[, measure]
## t = -1.7987, df = 167, p-value = 0.07387
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.28293088  0.01337949
## sample estimates:
##       cor 
## -0.137859 
## 
## [1] "L3_acc"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$FPCN and data_for_plot[, measure]
## t = 1.1208, df = 168, p-value = 0.264
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06521038  0.23363422
## sample estimates:
##        cor 
## 0.08614944 
## 
## [1] "omnibus_span"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$FPCN and data_for_plot[, measure]
## t = 1.011, df = 168, p-value = 0.3135
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07360969  0.22563932
## sample estimates:
##        cor 
## 0.07776616
plot_list[["DMN"]][["omnibus_span"]]+ plot_list[["DMN"]][["L3_acc"]] + plot_list[["DMN"]][["BPRS"]] +
  plot_layout(ncol=2)+
  plot_annotation("Average temporal ISC in DMN ROIs")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

for (measure in seq.int(7,9)){
  print(colnames(data_for_plot)[measure])
  print(cor.test(data_for_plot$DMN, data_for_plot[,measure]))
}
## [1] "BPRS"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DMN and data_for_plot[, measure]
## t = -0.090326, df = 167, p-value = 0.9281
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1577830  0.1441227
## sample estimates:
##          cor 
## -0.006989431 
## 
## [1] "L3_acc"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DMN and data_for_plot[, measure]
## t = 2.3467, df = 168, p-value = 0.02011
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02840307 0.32008683
## sample estimates:
##       cor 
## 0.1781557 
## 
## [1] "omnibus_span"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DMN and data_for_plot[, measure]
## t = 1.0827, df = 168, p-value = 0.2805
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06812651  0.23086306
## sample estimates:
##       cor 
## 0.0832413
plot_list[["DAN"]][["omnibus_span"]]+ plot_list[["DAN"]][["L3_acc"]] + plot_list[["DAN"]][["BPRS"]] +
  plot_layout(ncol=2)+
  plot_annotation("Average temporal ISC in DAN ROIs")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

for (measure in seq.int(7,9)){
  print(colnames(data_for_plot)[measure])
  print(cor.test(data_for_plot$DAN, data_for_plot[,measure]))
}
## [1] "BPRS"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DAN and data_for_plot[, measure]
## t = -1.8703, df = 167, p-value = 0.06319
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.287971161  0.007892701
## sample estimates:
##       cor 
## -0.143238 
## 
## [1] "L3_acc"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DAN and data_for_plot[, measure]
## t = 2.9392, df = 168, p-value = 0.003754
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.07306722 0.35969089
## sample estimates:
##       cor 
## 0.2211494 
## 
## [1] "omnibus_span"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$DAN and data_for_plot[, measure]
## t = 1.5391, df = 168, p-value = 0.1257
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03318511  0.26375122
## sample estimates:
##       cor 
## 0.1179181
plot_list[["VAN"]][["omnibus_span"]]+ plot_list[["VAN"]][["L3_acc"]] + plot_list[["VAN"]][["BPRS"]] +
  plot_layout(ncol=2)+
  plot_annotation("Average temporal ISC in VAN ROIs")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

for (measure in seq.int(7,9)){
  print(colnames(data_for_plot)[measure])
  print(cor.test(data_for_plot$VAN, data_for_plot[,measure]))
}
## [1] "BPRS"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$VAN and data_for_plot[, measure]
## t = -1.6153, df = 167, p-value = 0.1081
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.26993505  0.02744475
## sample estimates:
##        cor 
## -0.1240291 
## 
## [1] "L3_acc"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$VAN and data_for_plot[, measure]
## t = 0.20117, df = 168, p-value = 0.8408
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1353115  0.1656461
## sample estimates:
##        cor 
## 0.01551879 
## 
## [1] "omnibus_span"
## 
##  Pearson's product-moment correlation
## 
## data:  data_for_plot$VAN and data_for_plot[, measure]
## t = 1.464, df = 168, p-value = 0.1451
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03893637  0.25838497
## sample estimates:
##       cor 
## 0.1122356

Pairwise

high_pairwise_sig <- high_correct_ISC_pairwise[,,LOO_results$sig_corrected]
low_pairwise_sig <- low_correct_ISC_pairwise[,,LOO_results$sig_corrected]
load_effect_pairwise <- high_pairwise_sig - low_pairwise_sig

visual_pairwise_L3 <- high_pairwise_sig[,,c(1:7,34:39)]
dorsal_attn_pairwise_L3 <- high_pairwise_sig[,,c(8:14,40:49)]
ventral_attn_pairwise_L3 <- high_pairwise_sig[,,c(15:17,50:53)]
FPCN_pairwise_L3 <- high_pairwise_sig[,,c(18:23,54:59)]
DMN_pairwise_L3 <- high_pairwise_sig[,,c(25:33,61:64)]

network_pairwise_high_load <- list(visual = apply(visual_pairwise_L3, c(1,2), mean), FPCN = apply(FPCN_pairwise_L3, c(1,2), mean), DMN = apply(DMN_pairwise_L3, c(1,2), mean), DAN = apply(dorsal_attn_pairwise_L3, c(1,2), mean), VAN = apply(ventral_attn_pairwise_L3, c(1,2), mean))

visual_pairwise <- load_effect_pairwise[,,c(1:7,34:39)]
dorsal_attn_pairwise <- load_effect_pairwise[,,c(8:14,40:49)]
ventral_attn_pairwise <- load_effect_pairwise[,,c(15:17,50:53)]
FPCN_pairwise <- load_effect_pairwise[,,c(18:23,54:59)]
DMN_pairwise <- load_effect_pairwise[,,c(25:33,61:64)]

network_pairwise <- list(visual = apply(visual_pairwise, c(1,2), mean), FPCN = apply(FPCN_pairwise, c(1,2), mean), 
                         DMN = apply(DMN_pairwise, c(1,2), mean), DAN = apply(dorsal_attn_pairwise, c(1,2), mean), 
                         VAN = apply(ventral_attn_pairwise, c(1,2), mean))
# reorder based on span 
span_order <- order(constructs_fMRI$omnibus_span_no_DFR_MRI)

network_pairwise_span_ordered_high_load <- list()
network_pairwise_span_ordered <- list()
for (network in seq.int(1,5)){
  network_pairwise_span_ordered_high_load[[network]] <- network_pairwise_high_load[[network]][span_order, span_order]
  network_pairwise_span_ordered[[network]] <- network_pairwise[[network]][span_order, span_order]
}
network_graphs_high_load <- list()

for (network in seq.int(1,5)){
  data <- data.frame(network_pairwise_span_ordered_high_load[[network]][,])
  rownames(data) <- c(1:170)
  colnames(data) <- c(1:170)
  data %>%
    
    # Data wrangling
    as_tibble() %>%
    rowid_to_column(var="X") %>%
    gather(key="Y", value="Z", -1) %>% 
    
    # Change Y to numeric
    mutate(Y=as.numeric(gsub("V","",Y))) -> mutated_data
  # 
  ggplot(data=mutated_data,aes(X, Y, fill= Z)) +
    geom_tile() +
    scale_y_continuous(breaks = c(0,50,100,150),labels=c(0,50,100,150))+
    geom_hline(yintercept=57,color="black")+
    geom_hline(yintercept=114,color="black")+
    geom_vline(xintercept=57,color="black")+
    geom_vline(xintercept=114,color="black")+
    scale_fill_gradient2()+
    theme(aspect=1)+
    labs(fill="ISC")+
    ggtitle(paste("network:",names(network_pairwise)[network]))-> network_graphs_high_load[[network]]
}
network_graphs_load_effect <- list()

for (network in seq.int(1,5)){
  data <- data.frame(network_pairwise_span_ordered[[network]][,])
  rownames(data) <- c(1:170)
  colnames(data) <- c(1:170)
  data %>%
    
    # Data wrangling
    as_tibble() %>%
    rowid_to_column(var="X") %>%
    gather(key="Y", value="Z", -1) %>% 
    
    # Change Y to numeric
    mutate(Y=as.numeric(gsub("V","",Y))) -> mutated_data
  # 
  ggplot(data=mutated_data,aes(X, Y, fill= Z)) +
    geom_tile() +
    scale_y_continuous(breaks = c(0,50,100,150),labels=c(0,50,100,150))+
    geom_hline(yintercept=57,color="black")+
    geom_hline(yintercept=114,color="black")+
    geom_vline(xintercept=57,color="black")+
    geom_vline(xintercept=114,color="black")+
    scale_fill_gradient2()+
    theme(aspect=1)+
    labs(fill="Load Effect")+
    ggtitle(paste("network:",names(network_pairwise)[network]))-> network_graphs_load_effect[[network]]
}

High Load

Visualize pairwise comparisons

network_graphs_high_load[[1]] 

network_graphs_high_load[[2]] 

network_graphs_high_load[[3]] 

network_graphs_high_load[[4]] 

network_graphs_high_load[[5]] 

t_test_res = data.frame(matrix(nrow=5,ncol=2)) 
colnames(t_test_res) <- c("t value","p value")
cols <- c("low_within","low_across","med_within","med_across","high_within","high_across")

group_means <- data.frame(matrix(nrow=5,ncol=6))
colnames(group_means) <- cols

group_se <- data.frame(matrix(nrow=5,ncol=6))
colnames(group_se) <- cols

avg_over_groups<- list(mean=data.frame(within = matrix(nrow=5,ncol=1),across = matrix(nrow=5,ncol=1)),
                       se=data.frame(within = matrix(nrow=5,ncol=1),across = matrix(nrow=5,ncol=1)))

split_list <- list()
all_ISC_list_high_load <- list()

for (network in seq.int(1:5)){
  
  # define dataframes 
  comps <- data.frame(within = matrix(nrow=170,ncol=1),across = matrix(nrow=170,ncol=1))
  
  split_by_groups <- data.frame(matrix(nrow=56,ncol=6))
  colnames(split_by_groups) <- cols
  
  # loop over all subjects and make comparisons
  for (suj in c(1:56, 58:113, 115:170)){
    if (suj < 57){
      comps$within[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][1:56,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][c(58:113,115:170),suj],na.rm=TRUE)
    }else if (suj > 57 & suj < 114){ 
      comps$within[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][58:113,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][c(1:56,115:170),suj],na.rm=TRUE)
    }else if (suj > 114){ 
      comps$within[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][115:170,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered_high_load[[network]][c(1:56,58:113),suj],na.rm=TRUE)}
    
  }
  all_ISC_list_high_load[[names(network_pairwise)[network]]] <- comps 
  
  # average over groups 
  avg_over_groups[["mean"]]$within[network] <- mean(comps$within, na.rm=TRUE)
  avg_over_groups[["mean"]]$across[network] <- mean(comps$across, na.rm=TRUE)
  avg_over_groups[["se"]]$within[network] <- se(comps$within)
  avg_over_groups[["se"]]$across[network] <- se(comps$across)
  
  avg_over_groups[["mean"]]$difference[network] <- avg_over_groups[["mean"]]$within[network] - avg_over_groups[["mean"]]$across[network]
  avg_over_groups[["se"]]$difference[network] <- se(comps$within - comps$across)
  
  # split by groups 
  split_by_groups$low_across <- comps$across[1:56]
  split_by_groups$low_within <- comps$within[1:56]
  
  split_by_groups$med_across <- comps$across[58:113]
  split_by_groups$med_within <- comps$within[58:113]
  
  split_by_groups$high_across <- comps$across[115:170]
  split_by_groups$high_within <- comps$within[115:170]
  
  split_list[[names(network_pairwise)[network]]] <- split_by_groups
  
  group_means[network,] <- colMeans(split_by_groups)
  for (group in seq.int(1,6)){
    group_se[network,group] <- se(split_by_groups[,group])
  }
  temp2 <- t.test(comps$within,comps$across,paired=TRUE,var.equal = FALSE)
  t_test_res[network,] <- c(temp2$statistic,temp2$p.value)
  
}

rownames(t_test_res) <- names(network_pairwise) 
print(t_test_res)
##           t value      p value
## visual -5.0995924 9.155685e-07
## FPCN    1.7065772 8.975943e-02
## DMN     2.4082910 1.711611e-02
## DAN    -3.1638297 1.850336e-03
## VAN    -0.3083997 7.581626e-01
bar_list <- list()
bar_plot_data <- data.frame(matrix(nrow = 30, ncol=7))
colnames(bar_plot_data) <- c("mean", "se", "network_name", "comparison", "WMC", "err_min", "err_max")
comparison_list <- c("within", "across")
WMC_list <- c("low", "med", "high")
row_count=1
#row for mean, se, network, comparison, WMC
for (network in seq.int(1,5)){
  for (WMC in seq.int(1,3)){
    for (comparison in seq.int(1,2)){
      col_to_look <- ((WMC-1)*2+1) + (comparison-1)
      bar_plot_data$mean[row_count] <- mean(split_list[[network]][,col_to_look])  
      bar_plot_data$se[row_count] <- group_se[network,col_to_look]
      bar_plot_data$err_min[row_count] <- bar_plot_data$mean[row_count] - bar_plot_data$se[row_count]
      bar_plot_data$err_max[row_count] <- bar_plot_data$mean[row_count] + bar_plot_data$se[row_count]
      bar_plot_data$network_name[row_count] <- names(network_pairwise)[network]
      bar_plot_data$comparison[row_count] <- comparison_list[comparison] 
      bar_plot_data$WMC[row_count] <- WMC_list[WMC]
      row_count = row_count+1
    }
  }
  
  bar_plot_data$comparison <- as.factor(bar_plot_data$comparison)
  bar_plot_data$WMC <- factor(bar_plot_data$WMC, levels=c("low", "med", "high"))
  
  bar_plot_data %>%
    filter(network_name == names(network_pairwise)[network]) %>%
    ggplot(aes(x=WMC, y= mean, fill=comparison))+
    geom_bar(stat="identity", position="dodge")+
    geom_errorbar(aes(ymin=err_min, ymax=err_max), position=position_dodge(0.9), width=0.2)+
    ylab("Mean ISC")+
    ggtitle(paste0("network:", names(network_pairwise)[network])) -> bar_list[[names(network_pairwise)[network]]]
  
  
}

Average over subjects

(bar_list[["visual"]] + bar_list[["FPCN"]]) +
  plot_layout(guides="collect")

(bar_list[["DMN"]]+ bar_list[["DAN"]])+
  plot_layout(guides="collect")

bar_list[["VAN"]] 

Compare to behavior

VAN - both to acc; trend to span within DAN - both to acc; trend to span within DMN - both to acc; across to span FPCN: across to acc; within to span visual: both to acc

for (network in seq.int(1,5)){
  data_to_plot <- data.frame(constructs_fMRI[span_order, c(1,7)], all_ISC_list_high_load[[network]])
  data_to_plot <- merge(data_to_plot, p200_clinical_zscores[,c(1,2,8)], by="PTID")
  data_to_plot <- merge(data_to_plot, p200_data[,c(1,7)], by="PTID")
  data_to_plot$BPRS_TOT[data_to_plot$BPRS_TOT > 4] <- NA
  
  
  print(names(network_pairwise)[network])
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=omnibus_span_no_DFR_MRI,y=within), fill="black")+
          geom_smooth(aes(x=omnibus_span_no_DFR_MRI,y=within), method="lm", color="black")+
          geom_point(aes(x=omnibus_span_no_DFR_MRI,y=across), color="red")+
          geom_smooth(aes(x=omnibus_span_no_DFR_MRI,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$omnibus_span_no_DFR_MRI, data_to_plot$within))
  print(cor.test(data_to_plot$omnibus_span_no_DFR_MRI, data_to_plot$across))
  
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=BPRS_TOT,y=within), fill="black")+
          geom_smooth(aes(x=BPRS_TOT,y=within), method="lm", color="black")+
          geom_point(aes(x=BPRS_TOT,y=across), color="red")+
          geom_smooth(aes(x=BPRS_TOT,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$BPRS_TOT, data_to_plot$within))
  print(cor.test(data_to_plot$BPRS_TOT, data_to_plot$across))
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=XDFR_MRI_ACC_L3,y=within), fill="black")+
          geom_smooth(aes(x=XDFR_MRI_ACC_L3,y=within), method="lm", color="black")+
          geom_point(aes(x=XDFR_MRI_ACC_L3,y=across), color="red")+
          geom_smooth(aes(x=XDFR_MRI_ACC_L3,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$XDFR_MRI_ACC_L3, data_to_plot$within))
  print(cor.test(data_to_plot$XDFR_MRI_ACC_L3, data_to_plot$across))
  
  
}
## [1] "visual"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 1.6012, df = 166, p-value = 0.1112
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.02861651  0.26970129
## sample estimates:
##       cor 
## 0.1233276 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.65654, df = 166, p-value = 0.5124
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1012987  0.2007545
## sample estimates:
##        cor 
## 0.05089162

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.2962, df = 165, p-value = 0.1967
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24847402  0.05226153
## sample estimates:
##        cor 
## -0.1003989 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -1.062, df = 165, p-value = 0.2898
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.23136068  0.07035191
## sample estimates:
##         cor 
## -0.08239195

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 4.8281, df = 166, p-value = 3.11e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2106881 0.4769721
## sample estimates:
##      cor 
## 0.350904 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 4.3218, df = 166, p-value = 2.659e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1750428 0.4478680
## sample estimates:
##       cor 
## 0.3180239 
## 
## [1] "FPCN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 3.5301, df = 166, p-value = 0.0005378
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1175399 0.3996663
## sample estimates:
##       cor 
## 0.2642469 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.72207, df = 166, p-value = 0.4713
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09626941  0.20562368
## sample estimates:
##      cor 
## 0.055956

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -0.23681, df = 165, p-value = 0.8131
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1698207  0.1338057
## sample estimates:
##         cor 
## -0.01843248 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -0.49557, df = 165, p-value = 0.6209
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1893063  0.1139799
## sample estimates:
##         cor 
## -0.03855101

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 1.7854, df = 166, p-value = 0.07602
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.01444652  0.28279595
## sample estimates:
##       cor 
## 0.1372635 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 2.284, df = 166, p-value = 0.02364
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02376943 0.31756789
## sample estimates:
##      cor 
## 0.174551 
## 
## [1] "DMN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 1.3469, df = 166, p-value = 0.1798
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.04819519  0.25142502
## sample estimates:
##       cor 
## 0.1039733 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = -0.3589, df = 166, p-value = 0.7201
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1785022  0.1240880
## sample estimates:
##         cor 
## -0.02784499

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.2239, df = 165, p-value = 0.2227
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24321220  0.05784485
## sample estimates:
##         cor 
## -0.09485197 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -1.1393, df = 165, p-value = 0.2562
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.23702809  0.06438283
## sample estimates:
##         cor 
## -0.08834454

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 3.6711, df = 166, p-value = 0.0003253
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1279205 0.4084847
## sample estimates:
##       cor 
## 0.2740229 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 3.9015, df = 166, p-value = 0.0001386
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1447645 0.4226834
## sample estimates:
##       cor 
## 0.2898217 
## 
## [1] "DAN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 1.8431, df = 166, p-value = 0.06709
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.01001055  0.28687263
## sample estimates:
##       cor 
## 0.1416139 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.34612, df = 166, p-value = 0.7297
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1250638  0.1775424
## sample estimates:
##        cor 
## 0.02685449

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -0.44108, df = 165, p-value = 0.6597
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1852164  0.1181613
## sample estimates:
##        cor 
## -0.0343181 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -0.31544, df = 165, p-value = 0.7528
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1757579  0.1277905
## sample estimates:
##         cor 
## -0.02454957

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 4.4445, df = 166, p-value = 1.605e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1837685 0.4550463
## sample estimates:
##       cor 
## 0.3261046 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 4.2078, df = 166, p-value = 4.212e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1668847 0.4411247
## sample estimates:
##     cor 
## 0.31045 
## 
## [1] "VAN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 1.921, df = 166, p-value = 0.05645
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.004034671  0.292347552
## sample estimates:
##       cor 
## 0.1474652 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.99438, df = 166, p-value = 0.3215
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07533739  0.22572996
## sample estimates:
##        cor 
## 0.07695015

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -0.64558, df = 165, p-value = 0.5194
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2005299  0.1024497
## sample estimates:
##         cor 
## -0.05019486 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -0.56907, df = 165, p-value = 0.5701
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1948131  0.1083328
## sample estimates:
##         cor 
## -0.04425894

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 1.9777, df = 166, p-value = 0.04962
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.0003166685 0.2963219344
## sample estimates:
##       cor 
## 0.1517192 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 2.2328, df = 166, p-value = 0.0269
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.01985964 0.31404637
## sample estimates:
##      cor 
## 0.170756

Load Effects

Visualize pairs

network_graphs_load_effect[[1]] 

network_graphs_load_effect[[2]] 

network_graphs_load_effect[[3]] 

network_graphs_load_effect[[4]] 

network_graphs_load_effect[[5]] 

t_test_res = data.frame(matrix(nrow=5,ncol=2)) 
colnames(t_test_res) <- c("t value","p value")
cols <- c("low_within","low_across","med_within","med_across","high_within","high_across")

group_means <- data.frame(matrix(nrow=5,ncol=6))
colnames(group_means) <- cols

group_se <- data.frame(matrix(nrow=5,ncol=6))
colnames(group_se) <- cols

avg_over_groups<- list(mean=data.frame(within = matrix(nrow=5,ncol=1),across = matrix(nrow=5,ncol=1)),
                       se=data.frame(within = matrix(nrow=5,ncol=1),across = matrix(nrow=5,ncol=1)))

split_list <- list()

all_ISC_list_LE <- list()

for (network in seq.int(1:5)){
  
  # define dataframes 
  comps <- data.frame(within = matrix(nrow=170,ncol=1),across = matrix(nrow=170,ncol=1))
  
  split_by_groups <- data.frame(matrix(nrow=56,ncol=6))
  colnames(split_by_groups) <- cols
  
  # loop over all subjects and make comparisons
  for (suj in c(1:56, 58:113, 115:170)){
    if (suj < 57){
      comps$within[suj] <- mean(network_pairwise_span_ordered[[network]][1:56,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered[[network]][c(58:113,115:170),suj],na.rm=TRUE)
    }else if (suj > 57 & suj < 114){ 
      comps$within[suj] <- mean(network_pairwise_span_ordered[[network]][58:113,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered[[network]][c(1:56,115:170),suj],na.rm=TRUE)
    }else if (suj > 114){ 
      comps$within[suj] <- mean(network_pairwise_span_ordered[[network]][115:170,suj],na.rm=TRUE)
      comps$across[suj] <- mean(network_pairwise_span_ordered[[network]][c(1:56,58:113),suj],na.rm=TRUE)
    }
  }
  
  all_ISC_list_LE[[names(network_pairwise)[network]]] <- comps 
  
  
  # average over groups 
  avg_over_groups[["mean"]]$within[network] <- mean(comps$within, na.rm=TRUE)
  avg_over_groups[["mean"]]$across[network] <- mean(comps$across, na.rm=TRUE)
  avg_over_groups[["se"]]$within[network] <- se(comps$within)
  avg_over_groups[["se"]]$across[network] <- se(comps$across)
  
  avg_over_groups[["mean"]]$difference[network] <- avg_over_groups[["mean"]]$within[network] - avg_over_groups[["mean"]]$across[network]
  avg_over_groups[["se"]]$difference[network] <- se(comps$within - comps$across)
  
  # split by groups 
  split_by_groups$low_across <- comps$across[1:56]
  split_by_groups$low_within <- comps$within[1:56]
  
  split_by_groups$med_across <- comps$across[58:113]
  split_by_groups$med_within <- comps$within[58:113]
  
  split_by_groups$high_across <- comps$across[115:170]
  split_by_groups$high_within <- comps$within[115:170]
  
  split_list[[names(network_pairwise)[network]]] <- split_by_groups
  
  group_means[network,] <- colMeans(split_by_groups)
  for (group in seq.int(1,6)){
    group_se[network,group] <- se(split_by_groups[,group])
  }
  temp2 <- t.test(comps$within,comps$across,paired=TRUE,var.equal = FALSE)
  t_test_res[network,] <- c(temp2$statistic,temp2$p.value)
  
}

rownames(t_test_res) <- names(network_pairwise) 
print(t_test_res)
##           t value     p value
## visual -1.0877393 0.278277558
## FPCN    3.3130726 0.001131379
## DMN     1.1234601 0.262854555
## DAN    -0.8727005 0.384079386
## VAN     1.6959284 0.091762824

Compare across groups

bar_list <- list()
bar_plot_data <- data.frame(matrix(nrow = 30, ncol=7))
colnames(bar_plot_data) <- c("mean", "se", "network_name", "comparison", "WMC", "err_min", "err_max")
comparison_list <- c("within", "across")
WMC_list <- c("low", "med", "high")
row_count=1
#row for mean, se, network, comparison, WMC
for (network in seq.int(1,5)){
  for (WMC in seq.int(1,3)){
    for (comparison in seq.int(1,2)){
      col_to_look <- ((WMC-1)*2+1) + (comparison-1)
      bar_plot_data$mean[row_count] <- mean(split_list[[network]][,col_to_look])  
      bar_plot_data$se[row_count] <- group_se[network,col_to_look]
      bar_plot_data$err_min[row_count] <- bar_plot_data$mean[row_count] - bar_plot_data$se[row_count]
      bar_plot_data$err_max[row_count] <- bar_plot_data$mean[row_count] + bar_plot_data$se[row_count]
      bar_plot_data$network_name[row_count] <- names(network_pairwise)[network]
      bar_plot_data$comparison[row_count] <- comparison_list[comparison] 
      bar_plot_data$WMC[row_count] <- WMC_list[WMC]
      row_count = row_count+1
    }
  }
  
  bar_plot_data$comparison <- as.factor(bar_plot_data$comparison)
  bar_plot_data$WMC <- factor(bar_plot_data$WMC, levels=c("low", "med", "high"))
  
  bar_plot_data %>%
    filter(network_name == names(network_pairwise)[network]) %>%
    ggplot(aes(x=WMC, y= mean, fill=comparison))+
    geom_bar(stat="identity", position="dodge")+
    geom_errorbar(aes(ymin=err_min, ymax=err_max), position=position_dodge(0.9), width=0.2)+
    ylab("Mean ISC")+
    ggtitle(paste0("network:", names(network_pairwise)[network])) -> bar_list[[names(network_pairwise)[network]]]
  
  
}
(bar_list[["visual"]] + bar_list[["FPCN"]]) +
  plot_layout(guides="collect")

(bar_list[["DMN"]]+ bar_list[["DAN"]])+
  plot_layout(guides="collect")

bar_list[["VAN"]] 

Relate to behavior

visual with acc within FPCN with span/within DMN with acc within and across DAN with span withi; with acc both; both with BPRS if outlier removed VAN within with span

for (network in seq.int(1,5)){
  data_to_plot <- data.frame(constructs_fMRI[span_order, c(1,7)], all_ISC_list_LE[[network]])
  data_to_plot <- merge(data_to_plot, p200_clinical_zscores[,c(1,2,8)], by="PTID")
  data_to_plot <- merge(data_to_plot, p200_data[,c(1,7)], by="PTID")
  data_to_plot$BPRS_TOT[data_to_plot$BPRS_TOT > 4] <- NA
  
  print(names(network_pairwise)[network])
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=omnibus_span_no_DFR_MRI,y=within), fill="black")+
          geom_smooth(aes(x=omnibus_span_no_DFR_MRI,y=within), method="lm", color="black")+
          geom_point(aes(x=omnibus_span_no_DFR_MRI,y=across), color="red")+
          geom_smooth(aes(x=omnibus_span_no_DFR_MRI,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$omnibus_span_no_DFR_MRI, data_to_plot$within))
  print(cor.test(data_to_plot$omnibus_span_no_DFR_MRI, data_to_plot$across))
  
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=BPRS_TOT,y=within), fill="black")+
          geom_smooth(aes(x=BPRS_TOT,y=within), method="lm", color="black")+
          geom_point(aes(x=BPRS_TOT,y=across), color="red")+
          geom_smooth(aes(x=BPRS_TOT,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$BPRS_TOT, data_to_plot$within))
  print(cor.test(data_to_plot$BPRS_TOT, data_to_plot$across))
  
  print(ggplot(data = data_to_plot)+
          geom_point(aes(x=XDFR_MRI_ACC_L3,y=within), fill="black")+
          geom_smooth(aes(x=XDFR_MRI_ACC_L3,y=within), method="lm", color="black")+
          geom_point(aes(x=XDFR_MRI_ACC_L3,y=across), color="red")+
          geom_smooth(aes(x=XDFR_MRI_ACC_L3,y=across), method="lm", color="red")+
          ylab("ISC")+
          ggtitle(paste0("network: "), names(network_pairwise)[network]))
  
  print(cor.test(data_to_plot$XDFR_MRI_ACC_L3, data_to_plot$within))
  print(cor.test(data_to_plot$XDFR_MRI_ACC_L3, data_to_plot$across))
  
  
}
## [1] "visual"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 0.72347, df = 166, p-value = 0.4704
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09616224  0.20572728
## sample estimates:
##        cor 
## 0.05606383 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.077256, df = 166, p-value = 0.9385
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1455458  0.1572631
## sample estimates:
##         cor 
## 0.005996103

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.2377, df = 165, p-value = 0.2176
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24421648  0.05678066
## sample estimates:
##         cor 
## -0.09590996 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -1.2493, df = 165, p-value = 0.2133
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24506491  0.05588109
## sample estimates:
##         cor 
## -0.09680401

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 2.2592, df = 166, p-value = 0.02517
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02187271 0.31586054
## sample estimates:
##       cor 
## 0.1727105 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 1.6242, df = 166, p-value = 0.1062
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.02684343  0.27134588
## sample estimates:
##       cor 
## 0.1250747 
## 
## [1] "FPCN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 2.5448, df = 166, p-value = 0.01184
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.04364479 0.33534507
## sample estimates:
##       cor 
## 0.1937741 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.57111, df = 166, p-value = 0.5687
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1078495  0.1943898
## sample estimates:
##        cor 
## 0.04428339

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.3264, df = 165, p-value = 0.1866
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.25066394  0.04993225
## sample estimates:
##        cor 
## -0.1027102 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -1.7045, df = 165, p-value = 0.09017
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.27785354  0.02073744
## sample estimates:
##        cor 
## -0.1315404

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 1.0952, df = 166, p-value = 0.275
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06757768  0.23311896
## sample estimates:
##        cor 
## 0.08469874 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 1.1392, df = 166, p-value = 0.2563
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06419362  0.23633052
## sample estimates:
##        cor 
## 0.08807219 
## 
## [1] "DMN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 1.4721, df = 166, p-value = 0.1429
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.0385545  0.2604512
## sample estimates:
##      cor 
## 0.113518 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.083877, df = 166, p-value = 0.9333
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1450427  0.1577643
## sample estimates:
##         cor 
## 0.006510009

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = 0.32537, df = 165, p-value = 0.7453
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1270299  0.1765070
## sample estimates:
##        cor 
## 0.02532216 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -0.53845, df = 165, p-value = 0.591
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1925209  0.1106858
## sample estimates:
##         cor 
## -0.04188179

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 2.1863, df = 166, p-value = 0.03019
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.0163018 0.3108348
## sample estimates:
##       cor 
## 0.1672987 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 2.3111, df = 166, p-value = 0.02206
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02583945 0.31942908
## sample estimates:
##       cor 
## 0.1765585 
## 
## [1] "DAN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 2.7707, df = 166, p-value = 0.006232
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.06076595 0.35049405
## sample estimates:
##       cor 
## 0.2102414 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.51, df = 166, p-value = 0.6107
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1125307  0.1898260
## sample estimates:
##        cor 
## 0.03955304

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.9661, df = 165, p-value = 0.05097
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2963526368  0.0005786435
## sample estimates:
##        cor 
## -0.1512982 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -2.1547, df = 165, p-value = 0.03264
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.30951640 -0.01391464
## sample estimates:
##        cor 
## -0.1654287

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 3.3413, df = 166, p-value = 0.00103
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1035562 0.3877038
## sample estimates:
##     cor 
## 0.25103 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 2.4909, df = 166, p-value = 0.01373
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.03954032 0.33169084
## sample estimates:
##       cor 
## 0.1898137 
## 
## [1] "VAN"

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$within
## t = 2.4846, df = 166, p-value = 0.01396
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.03906592 0.33126791
## sample estimates:
##       cor 
## 0.1893557 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$omnibus_span_no_DFR_MRI and data_to_plot$across
## t = 0.95383, df = 166, p-value = 0.3416
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07845706  0.22274954
## sample estimates:
##        cor 
## 0.07382977

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$within
## t = -1.6117, df = 165, p-value = 0.1089
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2712288  0.0278980
## sample estimates:
##       cor 
## -0.124493 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$BPRS_TOT and data_to_plot$across
## t = -1.6854, df = 165, p-value = 0.09379
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.27649686  0.02220636
## sample estimates:
##       cor 
## -0.130096

## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$within
## t = 0.44308, df = 166, p-value = 0.6583
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1176528  0.1848173
## sample estimates:
##        cor 
## 0.03436926 
## 
## 
##  Pearson's product-moment correlation
## 
## data:  data_to_plot$XDFR_MRI_ACC_L3 and data_to_plot$across
## t = 0.4127, df = 166, p-value = 0.6804
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1199763  0.1825400
## sample estimates:
##       cor 
## 0.0320151

Spatial ISC

This analysis looks at the inter-subject correlation in two different ROIs: a bilateral fusiform ROI from the AAL atlas, and a mask of all regions that showed high load > low load activation during the delay period of the DFR task.

In order to get this data, we extracted the model-free BOLD activity and applied minimal pre-processing using SPM8 (removing cosine, filtering, detrend and meaning the value across voxels). From there, we separated the data into trials. Because the data was jittered, decided that the onset of a trial should be considered the TR that contains the onset of the trial. Once we had the individual trials separated, we averaged over high and low load trials separately. Correlations were taken across all common voxels in the given mask for each pair of subjects for the high load trials, which is the data that we are showing below.

corr_temp <- read.mat("data/ISC_corr.mat")
## Warning in read.mat("data/ISC_corr.mat"): Function class type read as NULL:
suj_corr_fusiform <- corr_temp[["suj_corr"]]
corr_temp <- read.mat("data/ISC_corr_DFR_delay.mat")
## Warning in read.mat("data/ISC_corr_DFR_delay.mat"): Function class type read as
## NULL:
suj_corr_DFR <- corr_temp[["suj_corr"]]

suj_corr_fusiform[is.nan(suj_corr_fusiform)] <- NA
suj_corr_DFR[is.nan(suj_corr_DFR)] <- NA

source("helper_fxns/avg_ISC.R")
source("helper_fxns/corr_ISC.R")
span_order <- order(constructs_fMRI$omnibus_span_no_DFR_MRI)

fusiform_ISC_ordered <- suj_corr_fusiform[span_order,span_order,]
DFR_ISC_ordered <- suj_corr_DFR[span_order,span_order,]

# select out only subjects who were included in group analyses 

fusiform_ISC_ordered_group <- fusiform_ISC_ordered[c(1:56,58:113,115:170),c(1:56,58:113,115:170),]
DFR_ISC_ordered_group <- DFR_ISC_ordered[c(1:56,58:113,115:170),c(1:56,58:113,115:170),]

# remove NaNs
fusiform_ISC_ordered_group[is.nan(fusiform_ISC_ordered_group)] <- NA
DFR_ISC_ordered_group[is.nan(DFR_ISC_ordered_group)] <- NA
avg_ISC_fusiform <- avg_ISC(suj_corr_fusiform)
avg_ISC_DFR <- avg_ISC(suj_corr_DFR)

overall_avg_ISC_fusiform <- rowMeans(avg_ISC_fusiform)
overall_avg_ISC_DFR <- rowMeans(avg_ISC_DFR)

Fusiform

First looking at the fusiform mask allows us to get a sense as to what the visual cortex is doing. Seeing results here might reflect perceptual representation of the stimuli, and if we see correlations during delay, might suggest that subjects are maintaining the percept of the faces in a similar way.

graph_fusiform <- list()

for (TR in seq.int(1,14)){
  data <- data.frame(fusiform_ISC_ordered_group[,,TR])
  rownames(data) <- c(1:168)
  colnames(data) <- c(1:168)
  data %>%
    
    # Data wrangling
    as_tibble() %>%
    rowid_to_column(var="X") %>%
    gather(key="Y", value="Z", -1) %>% 
    
    # Change Y to numeric
    mutate(Y=as.numeric(gsub("V","",Y))) -> mutated_data
  # 
  ggplot(data=mutated_data,aes(X, Y, fill= Z)) +
    geom_tile() +
    scale_y_continuous(breaks = c(0,50,100,150),labels=c(0,50,100,150))+
    geom_hline(yintercept=56,color="black")+
    geom_hline(yintercept=113,color="black")+
    geom_vline(xintercept=56,color="black")+
    geom_vline(xintercept=113,color="black")+
    scale_fill_gradient2()+
    theme(aspect=1)+
    ggtitle(paste("TR:",TR))-> graph_fusiform[[TR]]
  
  if (TR > 1){
    graph_fusiform[[TR]][["theme"]][["legend.position"]] = "none"
  }
  
}

First, we want to just look at the correlations between subjects over time. We can see that peak intersubject correlations happen around TR 4-6, drop and then get higher around TR 8-9. These TRs correspond to the encoding period and the beginning of the probe period - when there are actually stimuli on the screen.

The lines here represent divisions between groups - subjects are sorted by span, starting with low span at the bottom left corner and moving up and to the right. There doesn’t really seem to be any pattern within or across groups.

(graph_fusiform[[1]]+graph_fusiform[[2]] + graph_fusiform[[3]]) +
  plot_layout(guides = "collect")+
  plot_annotation(title="Fusiform Mask")

(graph_fusiform[[4]] + graph_fusiform[[5]] + graph_fusiform[[6]])

(graph_fusiform[[7]] + graph_fusiform[[8]] + graph_fusiform[[9]])

(graph_fusiform[[10]] + graph_fusiform[[11]] + graph_fusiform[[12]])

(graph_fusiform[[13]] + graph_fusiform[[14]])

z_trans_fusiform <-  atanh(fusiform_ISC_ordered_group)
z_trans_fusiform[z_trans_fusiform==Inf] <- NA
z_trans_corr <- z_trans_fusiform

t_test_res_fusiform = data.frame(matrix(nrow=14,ncol=2)) 
colnames(t_test_res_fusiform) <- c("t value","p value")
cols <- c("low_within","low_across","med_within","med_across","high_within","high_across")

group_means_fusiform <- data.frame(matrix(nrow=14,ncol=6))
colnames(group_means_fusiform) <- cols

group_se_fusiform <- data.frame(matrix(nrow=14,ncol=6))
colnames(group_se_fusiform) <- cols

avg_over_groups_fusiform <- list(mean=data.frame(within = matrix(nrow=14,ncol=1),across = matrix(nrow=14,ncol=1)),
                                 se=data.frame(within = matrix(nrow=14,ncol=1),across = matrix(nrow=14,ncol=1)))

for (TR in seq.int(1:14)){
  
  # define dataframes 
  comps <- data.frame(within = matrix(nrow=168,ncol=1),across = matrix(nrow=168,ncol=1))
  
  
  
  split_by_groups <- data.frame(matrix(nrow=56,ncol=6))
  colnames(split_by_groups) <- cols
  
  # loop over all subjects and make comparisons
  for (suj in seq.int(1,168)){
    if (suj < 57){
      comps$within[suj] <- mean(z_trans_corr[1:56,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[57:168,suj,TR],na.rm=TRUE)
    }else if (suj > 56 & suj < 113){ 
      comps$within[suj] <- mean(z_trans_corr[57:112,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[c(1:56,113:168),suj,TR],na.rm=TRUE)
    }else if (suj > 112){ 
      comps$within[suj] <- mean(z_trans_corr[113:168,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[1:112,suj,TR],na.rm=TRUE)}
    
  }
  
  # average over groups 
  avg_over_groups_fusiform[["mean"]]$within[TR] <- mean(comps$within)
  avg_over_groups_fusiform[["mean"]]$across[TR] <- mean(comps$across)
  avg_over_groups_fusiform[["se"]]$within[TR] <- se(comps$within)
  avg_over_groups_fusiform[["se"]]$across[TR] <- se(comps$across)
  
  avg_over_groups_fusiform[["mean"]]$difference[TR] <- avg_over_groups_fusiform[["mean"]]$within[TR] - avg_over_groups_fusiform[["mean"]]$across[TR]
  avg_over_groups_fusiform[["se"]]$difference[TR] <- se(comps$within - comps$across)
  
  # split by groups 
  split_by_groups$low_across <- comps$across[1:56]
  split_by_groups$low_within <- comps$within[1:56]
  
  split_by_groups$med_across <- comps$across[57:112]
  split_by_groups$med_within <- comps$within[57:112]
  
  split_by_groups$high_across <- comps$across[113:168]
  split_by_groups$high_within <- comps$within[113:168]
  
  group_means_fusiform[TR,] <- colMeans(split_by_groups)
  for (group in seq.int(1,6)){
    group_se_fusiform[TR,group] <- se(split_by_groups[,group])
  }
  temp2 <- t.test(comps$within,comps$across,paired=TRUE,var.equal = FALSE)
  t_test_res_fusiform[TR,] <- c(temp2$statistic,temp2$p.value)
  
}

All time points are significantly different.

print(t_test_res_fusiform)
##     t value      p value
## 1  7.517220 3.250766e-12
## 2  7.849980 4.768215e-13
## 3  7.848735 4.802915e-13
## 4  8.747743 2.273005e-15
## 5  7.447015 4.850177e-12
## 6  7.812660 5.924367e-13
## 7  8.619990 4.929059e-15
## 8  7.227409 1.676167e-11
## 9  7.833776 5.239835e-13
## 10 9.036165 3.903853e-16
## 11 8.283708 3.705993e-14
## 12 7.685563 1.236713e-12
## 13 8.077969 1.253792e-13
## 14 7.637561 1.630710e-12

Next, we want to take a quick sanity check and see how just averaging across all subjects, but looking within and across groups. We see similar time courses to what we were seeing with the full matrices. It is interesting to note that within subject correlations are higher than across subject ones.

plot_temp <- melt(cbind(avg_over_groups_fusiform[["mean"]],time=c(1:14)),id.vars="time")[1:28,]
se_plot_temp <- melt(cbind(avg_over_groups_fusiform[["se"]],time=c(1:14)),id.vars="time")[1:28,]
plot_temp <- merge(plot_temp,se_plot_temp,by=c("time","variable"))
colnames(plot_temp) <- c("time","variable","mean","se")

ggplot(data=plot_temp)+
  geom_line(aes(x=time,y=mean,color=variable))+
  geom_ribbon(aes(x=time,ymin=mean-se,ymax=mean+se,fill=variable),alpha=0.2)+
  ggtitle("Fusiform ISC - regardless of WM group")+
  theme_classic()

The last analysis didn’t take into account the span of the subjects - now we’ll look at them.

Seems as though low capacity subjects show less within group correlation than the other two groups during encoding, but no real differences otherwise.

group_means_fusiform$TR <- c(1:14) 
group_se_fusiform$TR <- c(1:14) 

melted_group <-  melt(group_means_fusiform, id.vars="TR",value.name="mean")
melted_se <- melt(group_se_fusiform,id.vars="TR",value.name="se")

merge(melted_group,melted_se) %>% 
  ggplot()+
  geom_rect(data=rects,aes(xmin=xstart, xmax=xend, ymin = -Inf, ymax=Inf), fill="grey", alpha =0.4,show.legend = FALSE)+
  geom_line(aes(x=TR,y=mean,color=variable))+
  geom_ribbon(aes(x=TR,ymin=mean-se,ymax=mean+se,fill=variable),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ggtitle("Fusiform ISC")+
  theme_classic()-> graph

graph

If we average over time, there is a super strong correlation between accuracy and average ISC in the fusiform, but we don’t see that for any other relationship.

data_to_plot <- merge(constructs_fMRI,p200_clinical_zscores, by="PTID")
data_to_plot <- merge(data_to_plot,p200_data[,c(1,7)])

data_to_plot <- cbind(data_to_plot,overall_avg_ISC_fusiform,overall_avg_ISC_DFR)

cor.test(overall_avg_ISC_fusiform,data_to_plot$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_fusiform and data_to_plot$omnibus_span_no_DFR_MRI
## t = 0.76879, df = 168, p-value = 0.4431
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09212565  0.20787134
## sample estimates:
##        cor 
## 0.05920962
cor.test(overall_avg_ISC_fusiform,data_to_plot$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_fusiform and data_to_plot$XDFR_MRI_ACC_L3
## t = 4.2985, df = 168, p-value = 2.906e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1724315 0.4442430
## sample estimates:
##       cor 
## 0.3147762
cor.test(overall_avg_ISC_fusiform,data_to_plot$WHO_ST_S32)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_fusiform and data_to_plot$WHO_ST_S32
## t = -2.3527, df = 168, p-value = 0.0198
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.32049393 -0.02885634
## sample estimates:
##        cor 
## -0.1785949
cor.test(overall_avg_ISC_fusiform,data_to_plot$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_fusiform and data_to_plot$BPRS_TOT
## t = -2.2068, df = 168, p-value = 0.02868
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3105153 -0.0177806
## sample estimates:
##        cor 
## -0.1678457
ggplot(data=data_to_plot,aes(x=overall_avg_ISC_fusiform,omnibus_span_no_DFR_MRI))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC fusiform vs omnibus span")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_fusiform,XDFR_MRI_ACC_L3))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC fusiform vs L3 DFR Acc")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_fusiform,WHO_ST_S32))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC fusiform vs WHODAS")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_fusiform,BPRS_TOT))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC fusiform vs BPRS Total")
## `geom_smooth()` using formula 'y ~ x'

If we break this down by TR, we see signficant linear relationships between ISC and span at TRs 10 and 11, with WHODAS at TR 10 (but I’m not sure I trust this one…) and accuracy at TRs 1, 2, 4, 5, 6, 7, 10, 11, 12, and 13.

Overall, it seems that ISC during probe (and a little bit during encoding) is relate to performance and span.

corr_ISC(avg_ISC_fusiform,data_to_plot[,c(1,7)])
## [1] "TR: 1; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.44174, df = 168, p-value = 0.6592
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1170534  0.1836337
## sample estimates:
##       cor 
## 0.0340609 
## 
## [1] "TR: 2; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.49604, df = 168, p-value = 0.6205
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1129219  0.1876764
## sample estimates:
##        cor 
## 0.03824238 
## 
## [1] "TR: 3; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.23987, df = 168, p-value = 0.8107
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1685478  0.1323800
## sample estimates:
##         cor 
## -0.01850291 
## 
## [1] "TR: 4; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.286, df = 168, p-value = 0.7752
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1288822  0.1720032
## sample estimates:
##        cor 
## 0.02206003 
## 
## [1] "TR: 5; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.2198, df = 168, p-value = 0.2242
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.05763109  0.24081406
## sample estimates:
##        cor 
## 0.09369591 
## 
## [1] "TR: 6; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.82895, df = 168, p-value = 0.4083
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.0875305  0.2122994
## sample estimates:
##        cor 
## 0.06382461 
## 
## [1] "TR: 7; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.13219, df = 168, p-value = 0.895
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1405320  0.1604659
## sample estimates:
##        cor 
## 0.01019794 
## 
## [1] "TR: 8; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.2483, df = 168, p-value = 0.2137
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.05545089  0.24287333
## sample estimates:
##        cor 
## 0.09586345 
## 
## [1] "TR: 9; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.53512, df = 168, p-value = 0.5933
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1099465  0.1905814
## sample estimates:
##       cor 
## 0.0412504 
## 
## [1] "TR: 10; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.1486, df = 168, p-value = 0.882
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1392904  0.1616994
## sample estimates:
##        cor 
## 0.01146417 
## 
## [1] "TR: 11; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.1367, df = 168, p-value = 0.8914
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1401905  0.1608053
## sample estimates:
##        cor 
## 0.01054626 
## 
## [1] "TR: 12; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.19812, df = 168, p-value = 0.8432
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1355426  0.1654172
## sample estimates:
##        cor 
## 0.01528346 
## 
## [1] "TR: 13; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.31641, df = 168, p-value = 0.7521
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1265749  0.1742784
## sample estimates:
##        cor 
## 0.02440431
corr_ISC(avg_ISC_fusiform,data_to_plot[,c(1,8)])
## [1] "TR: 1; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.37776, df = 168, p-value = 0.7061
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1219165  0.1788623
## sample estimates:
##        cor 
## 0.02913237 
## 
## [1] "TR: 2; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.35656, df = 168, p-value = 0.7219
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1235267  0.1772793
## sample estimates:
##        cor 
## 0.02749879 
## 
## [1] "TR: 3; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.35491, df = 168, p-value = 0.7231
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1771560  0.1236521
## sample estimates:
##         cor 
## -0.02737162 
## 
## [1] "TR: 4; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.12753, df = 168, p-value = 0.8987
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1408843  0.1601157
## sample estimates:
##        cor 
## 0.00983859 
## 
## [1] "TR: 5; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.0666, df = 168, p-value = 0.2877
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06935561  0.22969361
## sample estimates:
##        cor 
## 0.08201479 
## 
## [1] "TR: 6; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.67653, df = 168, p-value = 0.4996
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09916796  0.20106115
## sample estimates:
##        cor 
## 0.05212431 
## 
## [1] "TR: 7; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.13903, df = 168, p-value = 0.8896
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1609805  0.1400141
## sample estimates:
##         cor 
## -0.01072615 
## 
## [1] "TR: 8; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.9152, df = 168, p-value = 0.3614
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08093818  0.21863060
## sample estimates:
##        cor 
## 0.07043412 
## 
## [1] "TR: 9; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.29518, df = 168, p-value = 0.7682
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1281859  0.1726901
## sample estimates:
##        cor 
## 0.02276761 
## 
## [1] "TR: 10; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.014412, df = 168, p-value = 0.9885
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1494274  0.1516008
## sample estimates:
##         cor 
## 0.001111903 
## 
## [1] "TR: 11; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.013473, df = 168, p-value = 0.9893
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1515300  0.1494982
## sample estimates:
##          cor 
## -0.001039466 
## 
## [1] "TR: 12; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.030905, df = 168, p-value = 0.9754
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1481831  0.1528437
## sample estimates:
##        cor 
## 0.00238433 
## 
## [1] "TR: 13; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.25723, df = 168, p-value = 0.7973
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1310638  0.1698489
## sample estimates:
##        cor 
## 0.01984186
corr_ISC(avg_ISC_fusiform,data_to_plot[,c(1,14)])
## [1] "TR: 1; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.69884, df = 168, p-value = 0.4856
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20270982  0.09746584
## sample estimates:
##         cor 
## -0.05383821 
## 
## [1] "TR: 2; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.90959, df = 168, p-value = 0.3643
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08136765  0.21821891
## sample estimates:
##        cor 
## 0.07000394 
## 
## [1] "TR: 3; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.22285, df = 168, p-value = 0.8239
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1336698  0.1672718
## sample estimates:
##        cor 
## 0.01719036 
## 
## [1] "TR: 4; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -1.5993, df = 168, p-value = 0.1116
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.26803576  0.02857902
## sample estimates:
##       cor 
## -0.122462 
## 
## [1] "TR: 5; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.013419, df = 168, p-value = 0.9893
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1495023  0.1515259
## sample estimates:
##         cor 
## 0.001035267 
## 
## [1] "TR: 6; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.52106, df = 168, p-value = 0.603
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1110175  0.1895363
## sample estimates:
##        cor 
## 0.04016791 
## 
## [1] "TR: 7; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.25612, df = 168, p-value = 0.7982
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1697653  0.1311484
## sample estimates:
##         cor 
## -0.01975587 
## 
## [1] "TR: 8; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -1.6492, df = 168, p-value = 0.101
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.27157223  0.02476761
## sample estimates:
##        cor 
## -0.1262172 
## 
## [1] "TR: 9; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.17654, df = 168, p-value = 0.8601
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1637974  0.1371766
## sample estimates:
##         cor 
## -0.01361889 
## 
## [1] "TR: 10; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.5313, df = 168, p-value = 0.5959
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1102373  0.1902977
## sample estimates:
##        cor 
## 0.04095651 
## 
## [1] "TR: 11; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.086451, df = 168, p-value = 0.9312
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1439891  0.1570263
## sample estimates:
##         cor 
## 0.006669701 
## 
## [1] "TR: 12; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.31785, df = 168, p-value = 0.751
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1264655  0.1743862
## sample estimates:
##        cor 
## 0.02451542 
## 
## [1] "TR: 13; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.94594, df = 168, p-value = 0.3455
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.22088193  0.07858766
## sample estimates:
##         cor 
## -0.07278757
corr_ISC(avg_ISC_fusiform,data_to_plot[,c(1,20)])
## [1] "TR: 1; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.67709, df = 168, p-value = 0.4993
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20110234  0.09912545
## sample estimates:
##         cor 
## -0.05216713 
## 
## [1] "TR: 2; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.43076, df = 168, p-value = 0.6672
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1828157  0.1178882
## sample estimates:
##         cor 
## -0.03321537 
## 
## [1] "TR: 3; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.18368, df = 168, p-value = 0.8545
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1366356  0.1643338
## sample estimates:
##        cor 
## 0.01417007 
## 
## [1] "TR: 4; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.064941, df = 168, p-value = 0.9483
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1554073  0.1456139
## sample estimates:
##          cor 
## -0.005010206 
## 
## [1] "TR: 5; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.56861, df = 168, p-value = 0.5704
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1073958  0.1930675
## sample estimates:
##        cor 
## 0.04382685 
## 
## [1] "TR: 6; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.0839, df = 168, p-value = 0.28
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06803305  0.23095196
## sample estimates:
##        cor 
## 0.08333454 
## 
## [1] "TR: 7; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.39633, df = 168, p-value = 0.6924
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1802486  0.1205051
## sample estimates:
##         cor 
## -0.03056353 
## 
## [1] "TR: 8; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.068564, df = 168, p-value = 0.9454
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1556800  0.1453402
## sample estimates:
##          cor 
## -0.005289722 
## 
## [1] "TR: 9; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.2684, df = 168, p-value = 0.7887
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1706852  0.1302173
## sample estimates:
##         cor 
## -0.02070277 
## 
## [1] "TR: 10; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.34134, df = 168, p-value = 0.7333
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1761420  0.1246826
## sample estimates:
##         cor 
## -0.02632565 
## 
## [1] "TR: 11; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.54558, df = 168, p-value = 0.5861
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1091499  0.1913582
## sample estimates:
##        cor 
## 0.04205525 
## 
## [1] "TR: 12; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.85236, df = 168, p-value = 0.3952
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08574165  0.21401989
## sample estimates:
##        cor 
## 0.06561944 
## 
## [1] "TR: 13; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.8583, df = 168, p-value = 0.3919
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08528764  0.21445625
## sample estimates:
##        cor 
## 0.06607481

DFR

The next step is to look at regions that are actually implicated in working memory.

graph_DFR <- list()

for (TR in seq.int(1,14)){
  data <- data.frame(DFR_ISC_ordered_group[,,TR])
  rownames(data) <- c(1:168)
  colnames(data) <- c(1:168)
  data %>%
    
    # Data wrangling
    as_tibble() %>%
    rowid_to_column(var="X") %>%
    gather(key="Y", value="Z", -1) %>% 
    
    # Change Y to numeric
    mutate(Y=as.numeric(gsub("V","",Y))) -> mutated_data
  # 
  ggplot(data=mutated_data,aes(X, Y, fill= Z)) +
    geom_tile() +
    scale_y_continuous(breaks = c(0,50,100,150),labels=c(0,50,100,150))+
    geom_hline(yintercept=56,color="black")+
    geom_hline(yintercept=113,color="black")+
    geom_vline(xintercept=56,color="black")+
    geom_vline(xintercept=113,color="black")+
    scale_fill_gradient2()+
    theme(aspect=1)+
    ggtitle(paste("TR:",TR))-> graph_DFR[[TR]]
  
  if (TR > 1){
    graph_DFR[[TR]][["theme"]][["legend.position"]] = "none"
  }
  
}

These correlations are not as strong as the fusiform mask, but we still do see an increase in correlations around TRs 5-6 (during encoding)

(graph_DFR[[1]]+graph_DFR[[2]] + graph_DFR[[3]]) +
  plot_layout(guides = "collect")+
  plot_annotation(title="DFR Mask")

(graph_DFR[[4]] + graph_DFR[[5]] + graph_DFR[[6]])

(graph_DFR[[7]] + graph_DFR[[8]] + graph_DFR[[9]])

(graph_DFR[[10]] + graph_DFR[[11]] + graph_DFR[[12]])

(graph_DFR[[13]] + graph_DFR[[14]])

z_trans_DFR <-  atanh(DFR_ISC_ordered_group)
z_trans_DFR[z_trans_DFR==Inf] <- NA
z_trans_corr <- z_trans_DFR

t_test_res_DFR = data.frame(matrix(nrow=14,ncol=2)) 
colnames(t_test_res_DFR) <- c("t value","p value")

group_means_DFR <- data.frame(matrix(nrow=14,ncol=6))
colnames(group_means_DFR) <- cols

group_se_DFR <- data.frame(matrix(nrow=14,ncol=6))
colnames(group_se_DFR) <- cols

avg_over_groups_DFR <- list(mean=data.frame(within = matrix(nrow=14,ncol=1),across = matrix(nrow=14,ncol=1)),
                            se=data.frame(within = matrix(nrow=14,ncol=1),across = matrix(nrow=14,ncol=1)))

for (TR in seq.int(1:14)){
  
  # define dataframes 
  comps <- data.frame(within = matrix(nrow=168,ncol=1),across = matrix(nrow=168,ncol=1))
  
  split_by_groups <- data.frame(matrix(nrow=56,ncol=6))
  colnames(split_by_groups) <- cols
  
  # loop over all subjects and make comparisons
  for (suj in seq.int(1,168)){
    if (suj < 57){
      comps$within[suj] <- mean(z_trans_corr[1:56,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[57:168,suj,TR],na.rm=TRUE)
    }else if (suj > 56 & suj < 113){ 
      comps$within[suj] <- mean(z_trans_corr[57:112,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[c(1:56,113:168),suj,TR],na.rm=TRUE)
    }else if (suj > 112){ 
      comps$within[suj] <- mean(z_trans_corr[113:168,suj,TR],na.rm=TRUE)
      comps$across[suj] <- mean(z_trans_corr[1:112,suj,TR],na.rm=TRUE)}
    
  }
  
  # average over groups 
  avg_over_groups_DFR[["mean"]]$within[TR] <- mean(comps$within)
  avg_over_groups_DFR[["mean"]]$across[TR] <- mean(comps$across)
  avg_over_groups_DFR[["se"]]$within[TR] <- se(comps$within)
  avg_over_groups_DFR[["se"]]$across[TR] <- se(comps$across)
  
  avg_over_groups_DFR[["mean"]]$difference[TR] <- avg_over_groups_DFR[["mean"]]$within[TR] - avg_over_groups_DFR[["mean"]]$across[TR]
  avg_over_groups_DFR[["se"]]$difference[TR] <- se(comps$within - comps$across)
  
  # split by groups 
  split_by_groups$low_across <- comps$across[1:56]
  split_by_groups$low_within <- comps$within[1:56]
  
  split_by_groups$med_across <- comps$across[57:112]
  split_by_groups$med_within <- comps$within[57:112]
  
  split_by_groups$high_across <- comps$across[113:168]
  split_by_groups$high_within <- comps$within[113:168]
  
  group_means_DFR[TR,] <- colMeans(split_by_groups)
  for (group in seq.int(1,6)){
    group_se_DFR[TR,group] <- se(split_by_groups[,group])
  }
  
  temp2 <- t.test(comps$within,comps$across,paired=TRUE,var.equal = FALSE)
  t_test_res_DFR[TR,] <- c(temp2$statistic,temp2$p.value)
  
}

All time points are significantly different.

print(t_test_res_DFR)
##     t value      p value
## 1  10.62819 1.769375e-20
## 2  10.75847 7.684782e-21
## 3  11.57843 3.906112e-23
## 4  11.14335 6.481272e-22
## 5  12.43721 1.488099e-25
## 6  11.82523 7.901208e-24
## 7  12.68754 2.924909e-26
## 8  11.74914 1.293633e-23
## 9  12.67752 3.121740e-26
## 10 11.88681 5.300672e-24
## 11 11.09377 8.919037e-22
## 12 11.86393 6.148470e-24
## 13 13.22862 8.690418e-28
## 14 11.53691 5.109548e-23

Reflecting that, we’re seeing lower correlations, but a similar effect that within group correlations are higher than across group. However, we’re not seeing as much of a bump in the probe period, and the peak in the encoding is slightly later than in the fusiform region.

plot_temp <- melt(cbind(avg_over_groups_DFR[["mean"]],time=c(1:14)),id.vars="time")[1:28,]
se_plot_temp <- melt(cbind(avg_over_groups_DFR[["se"]],time=c(1:14)),id.vars="time")[1:28,]
plot_temp <- merge(plot_temp,se_plot_temp,by=c("time","variable"))
colnames(plot_temp) <- c("time","variable","mean","se")

ggplot(data=plot_temp)+
  geom_line(aes(x=time,y=mean,color=variable))+
  geom_ribbon(aes(x=time,ymin=mean-se,ymax=mean+se,fill=variable),alpha=0.2)+
  ggtitle("DFR ISC - regardless of WM group")

At the beginning of the probe period, we’re starting to see potential differences across groups - it almost looks as though there is higher within subject correlations in the medium and high capacity subjects vs low capacity subjects during the probe period. Will need to do further stats to see if this is statistically significant.

group_means_DFR$TR <- c(1:14) 
group_se_DFR$TR <- c(1:14) 

melted_group <-  melt(group_means_DFR, id.vars="TR",value.name="mean")
melted_se <- melt(group_se_DFR,id.vars="TR",value.name="se")

merge(melted_group,melted_se) %>% 
  ggplot()+
  geom_rect(data=rects,aes(xmin=xstart, xmax=xend, ymin = -Inf, ymax=Inf), fill="grey", alpha =0.4,show.legend = FALSE)+
  geom_line(aes(x=TR,y=mean,color=variable))+
  geom_ribbon(aes(x=TR,ymin=mean-se,ymax=mean+se,fill=variable),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ggtitle("DFR ISC")+
  theme_classic() -> graph

graph

If we take the same plan of attack as before and look at the correlation between ISC averaged over the whole time course and cognitive/clinical measures, we’re seeing the same thing - nothing except a very strong correlation with performance.

cor.test(overall_avg_ISC_DFR,data_to_plot$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_DFR and data_to_plot$omnibus_span_no_DFR_MRI
## t = 1.0317, df = 168, p-value = 0.3037
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07202695  0.22714894
## sample estimates:
##        cor 
## 0.07934751
cor.test(overall_avg_ISC_DFR,data_to_plot$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_DFR and data_to_plot$XDFR_MRI_ACC_L3
## t = 5.5685, df = 168, p-value = 1e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2596474 0.5146711
## sample estimates:
##       cor 
## 0.3947352
cor.test(overall_avg_ISC_DFR,data_to_plot$WHO_ST_S32)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_DFR and data_to_plot$WHO_ST_S32
## t = -0.77335, df = 168, p-value = 0.4404
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20820677  0.09177802
## sample estimates:
##         cor 
## -0.05955898
cor.test(overall_avg_ISC_DFR,data_to_plot$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  overall_avg_ISC_DFR and data_to_plot$BPRS_TOT
## t = -0.75607, df = 168, p-value = 0.4507
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2069336  0.0930971
## sample estimates:
##         cor 
## -0.05823314
ggplot(data=data_to_plot,aes(x=overall_avg_ISC_DFR,omnibus_span_no_DFR_MRI))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC DFR vs omnibus span")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_DFR,XDFR_MRI_ACC_L3))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC DFR vs L3 DFR Acc")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_DFR,WHO_ST_S32))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC DFR vs WHODAS")
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=data_to_plot,aes(x=overall_avg_ISC_DFR,BPRS_TOT))+
  geom_point()+
  stat_smooth(method="lm")+
  ggtitle("Avg ISC DFR vs BPRS Total")
## `geom_smooth()` using formula 'y ~ x'

If we break it down by TR, we again see correlations between ISC in the DFR regions and omnibus span at TR 10 and 11, WHODAS at TR 10 (but same concerns as above), and accuracy at TRs 1, 2, 4, 5, 6, 7, 10, 11, 12, and 13.

corr_ISC(avg_ISC_DFR,data_to_plot[,c(1,7)])
## [1] "TR: 1; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.2683, df = 168, p-value = 0.2064
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.05391824  0.24431936
## sample estimates:
##        cor 
## 0.09738635 
## 
## [1] "TR: 2; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.75685, df = 168, p-value = 0.4502
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09303749  0.20699119
## sample estimates:
##        cor 
## 0.05829306 
## 
## [1] "TR: 3; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.24746, df = 168, p-value = 0.8049
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1318047  0.1691166
## sample estimates:
##        cor 
## 0.01908822 
## 
## [1] "TR: 4; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.57404, df = 168, p-value = 0.5667
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1069822  0.1934704
## sample estimates:
##       cor 
## 0.0442445 
## 
## [1] "TR: 5; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.50633, df = 168, p-value = 0.6133
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1121385  0.1884417
## sample estimates:
##        cor 
## 0.03903458 
## 
## [1] "TR: 6; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.44078, df = 168, p-value = 0.6599
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1171262  0.1835624
## sample estimates:
##        cor 
## 0.03398721 
## 
## [1] "TR: 7; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.74526, df = 168, p-value = 0.4572
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09392242  0.20613655
## sample estimates:
##        cor 
## 0.05740332 
## 
## [1] "TR: 8; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.32444, df = 168, p-value = 0.746
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1259652  0.1748791
## sample estimates:
##        cor 
## 0.02502352 
## 
## [1] "TR: 9; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.14285, df = 168, p-value = 0.8866
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1397255  0.1612673
## sample estimates:
##       cor 
## 0.0110205 
## 
## [1] "TR: 10; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 2.1608, df = 168, p-value = 0.03212
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.01428222 0.30735000
## sample estimates:
##      cor 
## 0.164443
## `geom_smooth()` using formula 'y ~ x'

## [1] "TR: 11; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 2.2695, df = 168, p-value = 0.02451
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02254113 0.31481220
## sample estimates:
##       cor 
## 0.1724702
## `geom_smooth()` using formula 'y ~ x'

## [1] "TR: 12; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.37686, df = 168, p-value = 0.7068
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1219848  0.1787952
## sample estimates:
##        cor 
## 0.02906309 
## 
## [1] "TR: 13; measure: omnibus_span_no_DFR_MRI"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.25791, df = 168, p-value = 0.7968
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1698995  0.1310125
## sample estimates:
##         cor 
## -0.01989402
corr_ISC(avg_ISC_DFR,data_to_plot[,c(1,8)])
## [1] "TR: 1; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.1317, df = 168, p-value = 0.2594
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06437342  0.23442867
## sample estimates:
##        cor 
## 0.08698362 
## 
## [1] "TR: 2; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.6237, df = 168, p-value = 0.5337
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1031968  0.1971520
## sample estimates:
##        cor 
## 0.04806405 
## 
## [1] "TR: 3; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.10981, df = 168, p-value = 0.9127
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1422240  0.1587834
## sample estimates:
##         cor 
## 0.008471626 
## 
## [1] "TR: 4; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.26501, df = 168, p-value = 0.7913
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1304736  0.1704319
## sample estimates:
##        cor 
## 0.02044205 
## 
## [1] "TR: 5; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.3187, df = 168, p-value = 0.7504
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1264014  0.1744493
## sample estimates:
##        cor 
## 0.02458048 
## 
## [1] "TR: 6; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.34559, df = 168, p-value = 0.7301
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1243600  0.1764595
## sample estimates:
##        cor 
## 0.02665315 
## 
## [1] "TR: 7; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.71612, df = 168, p-value = 0.4749
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09614689  0.20398620
## sample estimates:
##        cor 
## 0.05516569 
## 
## [1] "TR: 8; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.34673, df = 168, p-value = 0.7292
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1242732  0.1765449
## sample estimates:
##        cor 
## 0.02674121 
## 
## [1] "TR: 9; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.035094, df = 168, p-value = 0.972
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1531594  0.1478670
## sample estimates:
##         cor 
## -0.00270755 
## 
## [1] "TR: 10; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.6482, df = 168, p-value = 0.1012
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.02484239  0.27150292
## sample estimates:
##       cor 
## 0.1261435 
## 
## [1] "TR: 11; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.6708, df = 168, p-value = 0.09663
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.02311506  0.27310309
## sample estimates:
##      cor 
## 0.127844 
## 
## [1] "TR: 12; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.22152, df = 168, p-value = 0.825
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1671725  0.1337701
## sample estimates:
##         cor 
## -0.01708822 
## 
## [1] "TR: 13; measure: omnibus_span_no_DFR"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.75748, df = 168, p-value = 0.4498
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20703721  0.09298983
## sample estimates:
##         cor 
## -0.05834098
corr_ISC(avg_ISC_DFR,data_to_plot[,c(1,14)])
## [1] "TR: 1; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.087418, df = 168, p-value = 0.9304
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1570991  0.1439160
## sample estimates:
##          cor 
## -0.006744329 
## 
## [1] "TR: 2; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.036325, df = 168, p-value = 0.9711
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1477741  0.1532521
## sample estimates:
##         cor 
## 0.002802502 
## 
## [1] "TR: 3; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.37756, df = 168, p-value = 0.7062
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1219315  0.1788476
## sample estimates:
##        cor 
## 0.02911711 
## 
## [1] "TR: 4; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.4314, df = 168, p-value = 0.1542
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.04143404  0.25604878
## sample estimates:
##       cor 
## 0.1097647 
## 
## [1] "TR: 5; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.1514, df = 168, p-value = 0.8798
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1390785  0.1619099
## sample estimates:
##        cor 
## 0.01168027 
## 
## [1] "TR: 6; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.096783, df = 168, p-value = 0.923
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1578037  0.1432084
## sample estimates:
##          cor 
## -0.007466779 
## 
## [1] "TR: 7; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.5046, df = 168, p-value = 0.6145
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1122702  0.1883131
## sample estimates:
##        cor 
## 0.03890142 
## 
## [1] "TR: 8; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.86083, df = 168, p-value = 0.3906
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08509463  0.21464172
## sample estimates:
##        cor 
## 0.06626838 
## 
## [1] "TR: 9; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.11767, df = 168, p-value = 0.9065
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1593743  0.1416299
## sample estimates:
##          cor 
## -0.009077821 
## 
## [1] "TR: 10; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.7957, df = 168, p-value = 0.4273
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20985288  0.09007093
## sample estimates:
##         cor 
## -0.06127402 
## 
## [1] "TR: 11; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.39886, df = 168, p-value = 0.6905
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1203132  0.1804370
## sample estimates:
##        cor 
## 0.03075808 
## 
## [1] "TR: 12; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.35162, df = 168, p-value = 0.7256
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1239016  0.1769106
## sample estimates:
##        cor 
## 0.02711841 
## 
## [1] "TR: 13; measure: ANX_TS"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.0262, df = 168, p-value = 0.3062
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07244515  0.22675021
## sample estimates:
##        cor 
## 0.07892976
corr_ISC(avg_ISC_DFR,data_to_plot[,c(1,20)])
## [1] "TR: 1; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.40417, df = 168, p-value = 0.6866
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1199099  0.1808328
## sample estimates:
##        cor 
## 0.03116689 
## 
## [1] "TR: 2; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.70494, df = 168, p-value = 0.4818
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09700037  0.20316039
## sample estimates:
##        cor 
## 0.05430676 
## 
## [1] "TR: 3; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.28938, df = 168, p-value = 0.7726
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1286254  0.1722565
## sample estimates:
##        cor 
## 0.02232097 
## 
## [1] "TR: 4; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.29878, df = 168, p-value = 0.7655
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1279126  0.1729596
## sample estimates:
##        cor 
## 0.02304529 
## 
## [1] "TR: 5; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.0109, df = 168, p-value = 0.3135
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07361672  0.22563261
## sample estimates:
##        cor 
## 0.07775913 
## 
## [1] "TR: 6; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.97712, df = 168, p-value = 0.3299
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07620311  0.22316260
## sample estimates:
##        cor 
## 0.07517336 
## 
## [1] "TR: 7; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.7189, df = 168, p-value = 0.4732
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09593498  0.20419117
## sample estimates:
##        cor 
## 0.05537892 
## 
## [1] "TR: 8; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.0039749, df = 168, p-value = 0.9968
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1508140  0.1502145
## sample estimates:
##           cor 
## -0.0003066738 
## 
## [1] "TR: 9; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.20279, df = 168, p-value = 0.8395
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1351889  0.1657676
## sample estimates:
##        cor 
## 0.01564371 
## 
## [1] "TR: 10; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = -0.56241, df = 168, p-value = 0.5746
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1926079  0.1078677
## sample estimates:
##        cor 
## -0.0433504 
## 
## [1] "TR: 11; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 0.42793, df = 168, p-value = 0.6693
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1181036  0.1826046
## sample estimates:
##        cor 
## 0.03299723 
## 
## [1] "TR: 12; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.563, df = 168, p-value = 0.1199
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03136088  0.26544951
## sample estimates:
##       cor 
## 0.1197185 
## 
## [1] "TR: 13; measure: sum_lev1man"
## 
##  Pearson's product-moment correlation
## 
## data:  TR_data[, TR] and measure[, 2]
## t = 1.443, df = 168, p-value = 0.1509
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.04054615  0.25687966
## sample estimates:
##       cor 
## 0.1106433